﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using SmartSpace.Data;

namespace SsTool.Metadata.Windows
{
    /// <summary>
    /// Interaction logic for DictionaryTypeWindow.xaml
    /// </summary>
    public partial class DictionaryTypeWindow : Window
    {
        public DictionaryType DictionaryType { get; private set; }

        public DictionaryTypeWindow()
        {
            InitializeComponent();

            DictionaryType = new DictionaryType();
            DictionaryType.Id = Guid.NewGuid();

            this.DataContext = DictionaryType;
        }

        public DictionaryTypeWindow(DictionaryType dictionaryType)
        {
            InitializeComponent();
            DictionaryType = dictionaryType;

            this.DataContext = DictionaryType;
        }

        private void _ctlBtnCancel_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = false;
        }

        private void _ctlBtnSubmit_Click(object sender, RoutedEventArgs e)
        {
            IDataService dataService = App.Get<IDataService>();
            if (dataService.SaveDictionaryType(this.DictionaryType))
            {
                DialogResult = true;
            }
        }
    }
}
